package main.com.dhj.test01

object test03 {
    def main(args: Array[String]): Unit = {
        val obj01 = new Greeter("Hello, ", "!");
        val obj02 = new Greeter("Hello, ", "!");
        obj01.greet("Scala");
        println(obj01 == obj02);

        println("------------------------------------------------")

        val objA = Point(1, 2);
        val objB = Point(1, 2);
        val objC = Point(3, 2);
        objA.move("objA");
        println(objA == objB);
        println(objA == objC);

        println("------------------------------------------------");

        val id01 = IDFactory.create();
        val id02 = IDFactory.create();
        println(id01 + "---" + id02 + "====" + (id01 == id02));
    }


    private class Greeter(prefix: String, suffix: String) {
        def greet(name: String): Unit = {
            println(prefix + name + suffix);
        }
    }

    private case class Point(x: Int, y: Int) {
        def move(coordinate: String): Unit = {
            println(coordinate + " - " + x + " , " + y);
        }
    }

    private object IDFactory {
        private var cnt = 0;

        def create(): Int = {
            cnt += 1;
            println("cnt = " + cnt);
            return cnt;
        }
    }
}